package web.Permission;

import com.google.gson.Gson;
import entity.PermissionBean;
import services.PermissionServiceAll;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/PerSearchBylevelid")
public class PerSearchByLevelId extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json");
        int levelKeyIndex = Integer.parseInt(req.getParameter("levelKeyIndex"));
        List<PermissionBean> list = new PermissionServiceAll().SearchBylevelId(levelKeyIndex);
        Gson gson = new Gson();
        String json = gson.toJson(list);
        resp.getWriter().println(json);
    }
}
